package com.foreknow.example4;

public class Student {
    String name;
    int id;
    int score;



    public Student(String name, int id, int score) {
        this.name = name;
        this.id = id;
        this.score = score;
    }



    public void getSort(Student[] s1){
        for(int j = 1;j<s1.length;j++){
            for(int i = 0;i<s1.length-j;i++){
                if(s1[i].score < s1[i+1].score){
                    Student temp = s1[i];
                    s1[i] = s1[i+1];
                    s1[i+1] = temp;
                }
            }
        }
    }


    public static void main(String[] args) {
        Student st1 = new Student("张三",101,90);
        Student st2 = new Student("李四",102,80);
        Student st3 = new Student("王五",103,100);
        Student[] s = {st1,st2,st3};
        st2.getSort(s);
        for(int i = 0;i<s.length;i++){
            System.out.println(s[i].name+"同学的学号为"+s[i].id+",其成绩为"+s[i].score+",名次为"+(i+1));
        }
}
}
